# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pytest-runner
pkgbase=python-${_realname}
pkgname=("python3-${_realname}" "python2-${_realname}")
pkgver=5.1
pkgrel=1
pkgdesc="Invoke py.test as distutils command with dependency resolution"
arch=('any')
license=('MIT')
url="https://github.com/pytest-dev/pytest-runner"
makedepends=('python2-pytest' 'python3-pytest' 'python2-setuptools-scm' 'python3-setuptools-scm')
#checkdepends=('python3-pytest-virtualenv' 'python2-pytest-virtualenv' 'python3-pytest-flake8'
#              'python2-pytest-flake8')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/pytest-dev/pytest-runner/archive/$pkgver.tar.gz")
sha512sums=('79806b6370e2378b5f230181e265e3046739ebc3ece729d1e3805510b5fb2d34022d60b9071a5a036f3b2604ffedf14b403e9910f0c56a58adc5c51c84866146')

prepare() {
  for builddir in python{2,3}-build-${CARCH}; do
    rm -rf ${builddir} | true
    cp -r "${_realname}-${pkgver}" "${builddir}"
  done

  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
  for pver in {2,3}; do  
    msg "Python ${pver} build for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    python${pver} setup.py build
  done  
}

#check() {
#  cd "${srcdir}"/pytest-runner-${pkgver}
#  python setup.py egg_info
#  PYTHONPATH="$PWD" pytest

#  cd "${srcdir}"/pytest-runner-${pkgver}-py2
#  python2 setup.py egg_info
#  PYTHONPATH="$PWD" pytest2
#}

package_python3-pytest-runner() {
  depends=('python3-pytest')

   cd "${srcdir}/python3-build-${CARCH}"
  python3 setup.py install --root="${pkgdir}" --optimize=1
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_python2-pytest-runner() {
  depends=('python2-pytest')

  cd "${srcdir}/python2-build-${CARCH}"
  python2 setup.py install --root="${pkgdir}" --optimize=1
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
